package com.hl.sfzy.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hl.sfzy.entity.UserVue;
import com.hl.sfzy.entity.course.Course;
import com.hl.sfzy.mapper.UserVueMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @program: sfzy
 * @description: 孙源源-Vue用户管理
 * @author: Syy
 * @create: 2024-09-11 15:07
 **/
@Service
public class UserManageService {
    @Autowired
    private UserVueMapper userVueMapper;

    //分页查询全部
    public PageInfo<UserVue> selectAll(Integer page, Integer size) {
        PageHelper.startPage(page, size);
        List list = userVueMapper.selectAll();
        PageInfo pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    //新增用户
    public int insertUser(UserVue userVue) {
        return userVueMapper.insertSelective(userVue);
    }

    //删除用户
    public int deleteUser(Long id) {
        return userVueMapper.deleteByPrimaryKey(id);
    }

    //修改用户
    public int updateUser(UserVue userVue) {
        return userVueMapper.updateByPrimaryKeySelective(userVue);
    }

    //根据用户名模糊查询
    public PageInfo<UserVue> selectLikeUsername(Integer page, Integer size, String username) {
        PageHelper.startPage(page, size);
        List list = userVueMapper.selectLikeUsername(username);
        PageInfo<UserVue> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }
}
